//
//  UITextField+ZJTextField.m
//  ZJUIKit
//
//  Created by dzj on 2017/12/4.
//  Copyright © 2017年 kapokcloud. All rights reserved.
//

#import "UITextField+ZJTextField.h"

@implementation UITextField (ZJTextField)

+(instancetype)zj_textFieldWithFrame:(CGRect)frame textColor:(UIColor *)tColor fontSize:(float)fontSize placeText:(NSString *)placeText placeColor:(UIColor *)placeColor borderStyle:(UITextBorderStyle)borderStyle{
    UITextField *textfield = [[UITextField alloc]init];
    textfield.frame = frame;
    textfield.font =[UIFont systemFontOfSize:fontSize];
    textfield.textColor = tColor;
    textfield.placeholder = placeText;
    [textfield setValue:placeColor forKeyPath:@"_placeholderLabel.textColor"];
    textfield.borderStyle = borderStyle;
    return textfield;
}

+ (void)load{
    Method imp = class_getInstanceMethod([self class], @selector(initWithCoder:));
    Method myImp = class_getInstanceMethod([self class], @selector(myInitWithCoder:));
    method_exchangeImplementations(imp, myImp);
}

- (id)myInitWithCoder:(NSCoder *)aDecode{
    
    [self myInitWithCoder:aDecode];
    if (self) {
        // 部分不想改变字体的 把tag值设置成555跳过
        if (IS_IPHONE_5 || IS_IPHONE_4) {
            self.font = [UIFont systemFontOfSize:self.font.pointSize -IPHONE5_INCREMENT];
        }else if (IS_IPHONE_6_PLUS){
            self.font = [UIFont systemFontOfSize:self.font.pointSize +IPHONE6PLUS_INCREMENT];
        }else{
            self.font = [UIFont systemFontOfSize:self.font.pointSize];
        }
    }
    return self;
}
@end
